home *** CD-ROM | disk | FTP | other *** search
- package sun.net;
-
- import java.net.URL;
-
- public class ProgressSource {
- private URL url;
- private String method;
- private String contentType;
- private int progress;
- private int lastProgress;
- private int expected;
- private State state;
- private boolean connected;
- private int threshold;
- private ProgressMonitor progressMonitor;
-
- public ProgressSource(URL var1, String var2) {
- this(var1, var2, -1);
- }
-
- public ProgressSource(URL var1, String var2, int var3) {
- this.progress = 0;
- this.lastProgress = 0;
- this.expected = -1;
- this.connected = false;
- this.threshold = 8192;
- this.url = var1;
- this.method = var2;
- this.contentType = "content/unknown";
- this.progress = 0;
- this.lastProgress = 0;
- this.expected = var3;
- this.state = sun.net.ProgressSource.State.NEW;
- this.progressMonitor = ProgressMonitor.getDefault();
- this.threshold = this.progressMonitor.getProgressUpdateThreshold();
- }
-
- public boolean connected() {
- if (!this.connected) {
- this.connected = true;
- this.state = sun.net.ProgressSource.State.CONNECTED;
- return false;
- } else {
- return true;
- }
- }
-
- public void close() {
- this.state = sun.net.ProgressSource.State.DELETE;
- }
-
- public URL getURL() {
- return this.url;
- }
-
- public String getMethod() {
- return this.method;
- }
-
- public String getContentType() {
- return this.contentType;
- }
-
- public void setContentType(String var1) {
- this.contentType = var1;
- }
-
- public int getProgress() {
- return this.progress;
- }
-
- public int getExpected() {
- return this.expected;
- }
-
- public State getState() {
- return this.state;
- }
-
- public void beginTracking() {
- this.progressMonitor.registerSource(this);
- }
-
- public void finishTracking() {
- this.progressMonitor.unregisterSource(this);
- }
-
- public void updateProgress(int var1, int var2) {
- this.lastProgress = this.progress;
- this.progress = var1;
- this.expected = var2;
- if (!this.connected()) {
- this.state = sun.net.ProgressSource.State.CONNECTED;
- } else {
- this.state = sun.net.ProgressSource.State.UPDATE;
- }
-
- if (this.lastProgress / this.threshold != this.progress / this.threshold) {
- this.progressMonitor.updateProgress(this);
- }
-
- if (this.expected != -1 && this.progress >= this.expected && this.progress != 0) {
- this.close();
- }
-
- }
-
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
- public String toString() {
- return this.getClass().getName() + "[url=" + this.url + ", method=" + this.method + ", state=" + this.state + ", content-type=" + this.contentType + ", progress=" + this.progress + ", expected=" + this.expected + "]";
- }
- }
-